<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Navo Portable Library: navo/algorithm/nonlinear/binary/splaylnk.h源文件</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<!-- 制作者 Doxygen 1.7.3 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'搜索');
--></script>
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">Navo Portable Library&#160;<span id="projectnumber">Ver 1.0.20120827</span></div>
   <div id="projectbrief">Provides generic platform independent facilities.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>首页</span></a></li>
      <li><a href="modules.html"><span>模块</span></a></li>
      <li><a href="annotated.html"><span>数据结构</span></a></li>
      <li class="current"><a href="files.html"><span>文件</span></a></li>
      <li id="searchli">
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="搜索" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>文件列表</span></a></li>
      <li><a href="globals.html"><span>全局定义</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<h1>navo/algorithm/nonlinear/binary/splaylnk.h</h1>  </div>
</div>
<div class="contents">
<a href="splaylnk_8h.html">浏览该文件的文档。</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */</span>
<a name="l00011"></a>00011 <span class="preprocessor">#ifdef _MSC_VER</span>
<a name="l00012"></a>00012 <span class="preprocessor"></span><span class="preprocessor">#pragma once</span>
<a name="l00013"></a>00013 <span class="preprocessor"></span><span class="preprocessor">#endif </span><span class="comment">/* #ifdef _MSC_VER */</span>
<a name="l00014"></a>00014 
<a name="l00015"></a>00015 <span class="preprocessor">#ifndef __NV_SPLAYLNK__</span>
<a name="l00016"></a>00016 <span class="preprocessor"></span><span class="preprocessor">#define __NV_SPLAYLNK__</span>
<a name="l00017"></a>00017 <span class="preprocessor"></span>
<a name="l00018"></a>00018 <span class="preprocessor">#include &quot;<a class="code" href="cdef_8h.html" title="Definitions and declarations for common constants, types, variables.">../../../port/cdef.h</a>&quot;</span>
<a name="l00019"></a>00019 <span class="preprocessor">#include &quot;<a class="code" href="integer_8h.html" title="Provides standard integer types.">../../../port/integer.h</a>&quot;</span>
<a name="l00020"></a>00020 
<a name="l00021"></a>00021 <span class="preprocessor">#ifdef __cplusplus</span>
<a name="l00022"></a>00022 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> {
<a name="l00023"></a>00023 <span class="preprocessor">#endif  </span><span class="comment">/* #ifdef __cplusplus */</span>
<a name="l00024"></a>00024 
<a name="l00039"></a><a class="code" href="struct____splaylnk__node.html">00039</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct____splaylnk__node.html" title="伸展树节点">__splaylnk_node</a> {
<a name="l00041"></a><a class="code" href="struct____splaylnk__node.html#a1b8aa83724dda5b481330b8ca569cdc0">00041</a>     <span class="keyword">struct </span><a class="code" href="struct____splaylnk__node.html" title="伸展树节点">__splaylnk_node</a>* <a class="code" href="struct____splaylnk__node.html#a1b8aa83724dda5b481330b8ca569cdc0" title="父节点">parent</a>;
<a name="l00043"></a><a class="code" href="struct____splaylnk__node.html#aa0ed7aab4acf06a006c61aa96e4cd5a1">00043</a>     <span class="keyword">struct </span><a class="code" href="struct____splaylnk__node.html" title="伸展树节点">__splaylnk_node</a>* <a class="code" href="struct____splaylnk__node.html#aa0ed7aab4acf06a006c61aa96e4cd5a1" title="左子节点">left</a>;
<a name="l00045"></a><a class="code" href="struct____splaylnk__node.html#adbcf818bcfba554a383e453874ad29a4">00045</a>     <span class="keyword">struct </span><a class="code" href="struct____splaylnk__node.html" title="伸展树节点">__splaylnk_node</a>* <a class="code" href="struct____splaylnk__node.html#adbcf818bcfba554a383e453874ad29a4" title="右子节点">right</a>;
<a name="l00046"></a>00046 }<a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga86d63f86085373735ef646def7b11623" title="节点">splaylnk_node</a>, *<a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gad419d6203da790205c3ced27085c87ad" title="迭代器">splaylnk_iter</a>;
<a name="l00047"></a>00047 
<a name="l00052"></a><a class="code" href="structsplaylnk__root.html">00052</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
<a name="l00054"></a><a class="code" href="structsplaylnk__root.html#ad1a7b82ff33bd008821a73024d7c3576">00054</a>     <a class="code" href="struct____splaylnk__node.html" title="伸展树节点">splaylnk_node</a>* <a class="code" href="structsplaylnk__root.html#ad1a7b82ff33bd008821a73024d7c3576" title="根节点">node</a>;
<a name="l00055"></a>00055 }<a class="code" href="structsplaylnk__root.html" title="树根">splaylnk_root</a>;
<a name="l00056"></a>00056 
<a name="l00061"></a><a class="code" href="structsplaylnk__info.html">00061</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
<a name="l00063"></a><a class="code" href="structsplaylnk__info.html#a76d971a3c552bc58ba9f0d5fceae9806">00063</a>     <span class="keywordtype">size_t</span> <a class="code" href="structsplaylnk__info.html#a76d971a3c552bc58ba9f0d5fceae9806" title="节点数">count</a>;
<a name="l00065"></a><a class="code" href="structsplaylnk__info.html#a820c167ceaaa9759b0ca2695d22db55c">00065</a>     <span class="keywordtype">size_t</span> <a class="code" href="structsplaylnk__info.html#a820c167ceaaa9759b0ca2695d22db55c" title="深度">depth</a>;
<a name="l00067"></a><a class="code" href="structsplaylnk__info.html#a62f3b2ad4f6c6147d1bb9a71dd8c9656">00067</a>     <span class="keywordtype">size_t</span> <a class="code" href="structsplaylnk__info.html#a62f3b2ad4f6c6147d1bb9a71dd8c9656" title="叶子数">leafs</a>;
<a name="l00068"></a>00068 }<a class="code" href="structsplaylnk__info.html" title="树信息表">splaylnk_info</a>;
<a name="l00069"></a>00069 
<a name="l00081"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga459d1dd1b0388a3116016c6f6f0bdd76">00081</a> <span class="preprocessor">#define SPLAYLNK_ROOT(name) splaylnk_root name = {NULL}</span>
<a name="l00082"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga9913599b9f3015bb4519fd0bf8f2bd55">00082</a> <span class="preprocessor"></span><span class="preprocessor">#define SPLAYLNK_NODE(name) splaylnk_node name = {NULL, NULL, NULL}</span>
<a name="l00083"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga97c4beedce8280f4c0da51e39e9e4dba">00083</a> <span class="preprocessor"></span><span class="preprocessor">#define SPLAYLNK_INFO(name) splaylnk_info name = {0, 0, 0}</span>
<a name="l00084"></a>00084 <span class="preprocessor"></span>
<a name="l00091"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gac07a47df24523e66c8f37863d68b3d59">00091</a> <span class="keyword">typedef</span> int (*<a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gac07a47df24523e66c8f37863d68b3d59" title="单参数回调函数指针">splaylnk_pr1</a>)(<a class="code" href="struct____splaylnk__node.html" title="伸展树节点">splaylnk_node</a>*);
<a name="l00092"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga379a0cb9429df29cf1fdda06a4f6f106">00092</a> <span class="keyword">typedef</span> int (*<a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga379a0cb9429df29cf1fdda06a4f6f106" title="双参数回调函数指针">splaylnk_pr2</a>)(<a class="code" href="struct____splaylnk__node.html" title="伸展树节点">splaylnk_node</a>*, splaylnk_node*);
<a name="l00093"></a>00093 
<a name="l00101"></a>00101 NV_API <span class="keywordtype">size_t</span> <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga96a0390c48c3efce2bfcc0d8e169d02c" title="获取树的节点总数">splaylnk_count</a>(<a class="code" href="structsplaylnk__root.html" title="树根">splaylnk_root</a>* root);
<a name="l00102"></a>00102 
<a name="l00111"></a>00111 NV_API <span class="keywordtype">size_t</span> <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga184ab3bc7e5856c525fa69b1c0894dc7" title="计算两个节点的迭代距离">splaylnk_distance</a>(splaylnk_iter first, splaylnk_iter last);
<a name="l00112"></a>00112 
<a name="l00121"></a>00121 NV_API <span class="keywordtype">size_t</span> <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga54bf3a666d7d44370c76f84ebb016dfa" title="计算迭代器的正向索引">splaylnk_index_of</a>(<a class="code" href="structsplaylnk__root.html" title="树根">splaylnk_root</a>* root, splaylnk_iter itr);
<a name="l00122"></a>00122 
<a name="l00131"></a>00131 NV_API <span class="keywordtype">size_t</span> <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gab24b1de0094f3caac4b04b22ecc9006e" title="计算迭代器的逆向索引">splaylnk_reverse_index_of</a>(<a class="code" href="structsplaylnk__root.html" title="树根">splaylnk_root</a>* root, 
<a name="l00132"></a>00132                                     splaylnk_iter itr);
<a name="l00133"></a>00133 
<a name="l00141"></a>00141 NV_API <span class="keywordtype">size_t</span> <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gab8d130bbc63ec59e932b631666893aeb" title="计算树的深度">splaylnk_depth</a>(<a class="code" href="structsplaylnk__root.html" title="树根">splaylnk_root</a>* root);
<a name="l00142"></a>00142 
<a name="l00150"></a>00150 NV_API <span class="keywordtype">size_t</span> <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gad3e72453d2045135cb2f4ea45e170ebf" title="计算树的叶子数">splaylnk_leafs</a>(<a class="code" href="structsplaylnk__root.html" title="树根">splaylnk_root</a>* root);
<a name="l00151"></a>00151 
<a name="l00159"></a>00159 NV_API <span class="keywordtype">void</span> <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga047a6df159da0ec6e9b865a81cdbd2ad" title="获取树的信息，包括节点数、深度、叶子数">splaylnk_get_info</a>(<a class="code" href="structsplaylnk__root.html" title="树根">splaylnk_root</a>* root, <a class="code" href="structsplaylnk__info.html" title="树信息表">splaylnk_info</a>* info);
<a name="l00160"></a>00160 
<a name="l00204"></a>00204 NV_API <span class="keywordtype">void</span> <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gada68906d6a788a0c39d67127f037e875" title="对节点进行伸展调整">splaylnk_splay</a>(<a class="code" href="structsplaylnk__root.html" title="树根">splaylnk_root</a>* root, splaylnk_node* node, 
<a name="l00205"></a>00205                             splaylnk_node* parent);
<a name="l00206"></a>00206 
<a name="l00250"></a>00250 NV_API <span class="keywordtype">void</span> <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gaaa0524284fb74c268dde8f245219f34f" title="对节点进行半伸展调整">splaylnk_semisplay</a>(<a class="code" href="structsplaylnk__root.html" title="树根">splaylnk_root</a>* root, splaylnk_node* node, 
<a name="l00251"></a>00251                                     splaylnk_node* parent);
<a name="l00252"></a>00252 
<a name="l00259"></a>00259 NV_API <span class="keywordtype">void</span> <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga5a5a89278bf4369487a3fbd73fa76f3f" title="移除某个节点(伸展)">splaylnk_erase</a>(<a class="code" href="structsplaylnk__root.html" title="树根">splaylnk_root</a>* root, splaylnk_node* entry);
<a name="l00260"></a>00260 
<a name="l00267"></a>00267 NV_API <span class="keywordtype">void</span> <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga967ec8dd9063af617b682ea2760f1829" title="移除某个节点(半伸展)">splaylnk_semierase</a>(<a class="code" href="structsplaylnk__root.html" title="树根">splaylnk_root</a>* root, splaylnk_node* entry);
<a name="l00268"></a>00268 
<a name="l00282"></a>00282 NV_API <span class="keywordtype">void</span> <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gaf8b8aa25afe97aafae97b716b29ef460" title="移除区域内的节点(伸展)">splaylnk_erases</a>(<a class="code" href="structsplaylnk__root.html" title="树根">splaylnk_root</a>* root, splaylnk_iter begin, 
<a name="l00283"></a>00283                             splaylnk_iter end, <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gac07a47df24523e66c8f37863d68b3d59" title="单参数回调函数指针">splaylnk_pr1</a> erase_handler);
<a name="l00284"></a>00284 
<a name="l00298"></a>00298 NV_API <span class="keywordtype">void</span> <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gaabe47843d251d2e8d3d9560e163af0ef" title="移除区域内的节点(半伸展)">splaylnk_semierases</a>(<a class="code" href="structsplaylnk__root.html" title="树根">splaylnk_root</a>* root, splaylnk_iter begin, 
<a name="l00299"></a>00299                                 splaylnk_iter end, <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gac07a47df24523e66c8f37863d68b3d59" title="单参数回调函数指针">splaylnk_pr1</a> erase_handler);
<a name="l00300"></a>00300 
<a name="l00312"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gac499691fdb6e46b0246fc7912c306282">00312</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gac499691fdb6e46b0246fc7912c306282" title="初始化树根">splaylnk_init</a>(<a class="code" href="structsplaylnk__root.html" title="树根">splaylnk_root</a>* root)
<a name="l00313"></a>00313 {
<a name="l00314"></a>00314     root-&gt;<a class="code" href="structsplaylnk__root.html#ad1a7b82ff33bd008821a73024d7c3576" title="根节点">node</a> = NULL;
<a name="l00315"></a>00315 }
<a name="l00316"></a>00316 
<a name="l00331"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga328c554736cee464fd77d3e0e4135a05">00331</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga328c554736cee464fd77d3e0e4135a05" title="判断树是否为空">splaylnk_empty</a>(<a class="code" href="structsplaylnk__root.html" title="树根">splaylnk_root</a>* root)
<a name="l00332"></a>00332 {
<a name="l00333"></a>00333     <span class="keywordflow">return</span> !root-&gt;<a class="code" href="structsplaylnk__root.html#ad1a7b82ff33bd008821a73024d7c3576" title="根节点">node</a>;
<a name="l00334"></a>00334 }
<a name="l00335"></a>00335 
<a name="l00336"></a>00336 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> __splaylnk_singular(splaylnk_node* root)
<a name="l00337"></a>00337 {
<a name="l00338"></a>00338     <span class="keywordflow">return</span> root &amp;&amp; !root-&gt;<a class="code" href="struct____splaylnk__node.html#aa0ed7aab4acf06a006c61aa96e4cd5a1" title="左子节点">left</a> &amp;&amp; !root-&gt;<a class="code" href="struct____splaylnk__node.html#adbcf818bcfba554a383e453874ad29a4" title="右子节点">right</a>;
<a name="l00339"></a>00339 }
<a name="l00340"></a>00340 
<a name="l00355"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gad807475fbd018c7899fc328d891ce1e8">00355</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gad807475fbd018c7899fc328d891ce1e8" title="判断树是否只有单个节点">splaylnk_singular</a>(<a class="code" href="structsplaylnk__root.html" title="树根">splaylnk_root</a>* root)
<a name="l00356"></a>00356 {
<a name="l00357"></a>00357     <span class="keywordflow">return</span> __splaylnk_singular(root-&gt;<a class="code" href="structsplaylnk__root.html#ad1a7b82ff33bd008821a73024d7c3576" title="根节点">node</a>);
<a name="l00358"></a>00358 }
<a name="l00359"></a>00359 
<a name="l00389"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga0d09988d46c22176f1f37ad3da562781">00389</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga0d09988d46c22176f1f37ad3da562781" title="判断树是否可以序列化">splaylnk_serialable</a>(<a class="code" href="structsplaylnk__root.html" title="树根">splaylnk_root</a>* root)
<a name="l00390"></a>00390 {
<a name="l00391"></a>00391     <span class="keywordflow">return</span> !!root-&gt;<a class="code" href="structsplaylnk__root.html#ad1a7b82ff33bd008821a73024d7c3576" title="根节点">node</a>;
<a name="l00392"></a>00392 }
<a name="l00393"></a>00393 
<a name="l00401"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga208a3a7318ac6710042ecdc877368ef2">00401</a> <span class="keyword">static</span> <span class="keyword">inline</span> splaylnk_iter <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga208a3a7318ac6710042ecdc877368ef2" title="得到左子节点">splaylnk_left</a>(splaylnk_node* node)
<a name="l00402"></a>00402 {
<a name="l00403"></a>00403     <span class="keywordflow">return</span> node-&gt;<a class="code" href="struct____splaylnk__node.html#aa0ed7aab4acf06a006c61aa96e4cd5a1" title="左子节点">left</a>;
<a name="l00404"></a>00404 }
<a name="l00405"></a>00405 
<a name="l00413"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga83961643a16aafa16240f70e67960bc1">00413</a> <span class="keyword">static</span> <span class="keyword">inline</span> splaylnk_iter <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga83961643a16aafa16240f70e67960bc1" title="得到右子节点">splaylnk_right</a>(splaylnk_node* node)
<a name="l00414"></a>00414 {
<a name="l00415"></a>00415     <span class="keywordflow">return</span> node-&gt;<a class="code" href="struct____splaylnk__node.html#adbcf818bcfba554a383e453874ad29a4" title="右子节点">right</a>;
<a name="l00416"></a>00416 }
<a name="l00417"></a>00417 
<a name="l00424"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga59c8e5d7719e7d97ef4d7b15ac31a4ff">00424</a> <span class="keyword">static</span> <span class="keyword">inline</span> splaylnk_iter <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga59c8e5d7719e7d97ef4d7b15ac31a4ff" title="得到父节点">splaylnk_parent</a>(splaylnk_node* node)
<a name="l00425"></a>00425 {
<a name="l00426"></a>00426     <span class="keywordflow">return</span> node-&gt;<a class="code" href="struct____splaylnk__node.html#a1b8aa83724dda5b481330b8ca569cdc0" title="父节点">parent</a>;
<a name="l00427"></a>00427 }
<a name="l00428"></a>00428 
<a name="l00437"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gacda2bc982d5a1762266955df6ae730b1">00437</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gacda2bc982d5a1762266955df6ae730b1" title="判断当前节点是否是根节点">splaylnk_is_root</a>(splaylnk_iter itr)
<a name="l00438"></a>00438 {
<a name="l00439"></a>00439     <span class="keywordflow">return</span> !itr-&gt;<a class="code" href="struct____splaylnk__node.html#a1b8aa83724dda5b481330b8ca569cdc0" title="父节点">parent</a>;
<a name="l00440"></a>00440 }
<a name="l00441"></a>00441 
<a name="l00450"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga07e12040dce0fbf4e87bb924cf43614b">00450</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga07e12040dce0fbf4e87bb924cf43614b" title="判断当前节点是否是叶子节点">splaylnk_is_leaf</a>(splaylnk_iter itr)
<a name="l00451"></a>00451 {
<a name="l00452"></a>00452     <span class="keywordflow">return</span> !itr-&gt;<a class="code" href="struct____splaylnk__node.html#aa0ed7aab4acf06a006c61aa96e4cd5a1" title="左子节点">left</a> &amp;&amp; !itr-&gt;<a class="code" href="struct____splaylnk__node.html#adbcf818bcfba554a383e453874ad29a4" title="右子节点">right</a>;
<a name="l00453"></a>00453 }
<a name="l00454"></a>00454 
<a name="l00466"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga23d333a84fee4942e550609f5cf08f6b">00466</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga23d333a84fee4942e550609f5cf08f6b" title="链接两个节点">splaylnk_link</a>(splaylnk_iter newly, 
<a name="l00467"></a>00467                 splaylnk_iter parent, splaylnk_iter* plink)
<a name="l00468"></a>00468 {
<a name="l00469"></a>00469     <span class="comment">/* 简单地将newly节点链接到parent节点下 */</span>
<a name="l00470"></a>00470     *plink = newly;
<a name="l00471"></a>00471     newly-&gt;<a class="code" href="struct____splaylnk__node.html#aa0ed7aab4acf06a006c61aa96e4cd5a1" title="左子节点">left</a> = NULL;
<a name="l00472"></a>00472     newly-&gt;<a class="code" href="struct____splaylnk__node.html#adbcf818bcfba554a383e453874ad29a4" title="右子节点">right</a> = NULL;
<a name="l00473"></a>00473     newly-&gt;<a class="code" href="struct____splaylnk__node.html#a1b8aa83724dda5b481330b8ca569cdc0" title="父节点">parent</a> = parent;
<a name="l00474"></a>00474 }
<a name="l00475"></a>00475 
<a name="l00483"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga0bc6c60eab55d8b1ff543b3bbd430277">00483</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga0bc6c60eab55d8b1ff543b3bbd430277" title="仅在node不为空时，设置node的父节点">splaylnk_set_parent_if</a>(splaylnk_node* node, 
<a name="l00484"></a>00484                                           splaylnk_node* parent)
<a name="l00485"></a>00485 {
<a name="l00486"></a>00486     <span class="keywordflow">if</span> (node)
<a name="l00487"></a>00487         node-&gt;<a class="code" href="struct____splaylnk__node.html#a1b8aa83724dda5b481330b8ca569cdc0" title="父节点">parent</a> = parent;
<a name="l00488"></a>00488 }
<a name="l00489"></a>00489 
<a name="l00495"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gabefb35778426452b53bc6a2a462a7548">00495</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gabefb35778426452b53bc6a2a462a7548" title="初始化节点">splaylnk_node_init</a>(splaylnk_node* node)
<a name="l00496"></a>00496 {
<a name="l00497"></a>00497     node-&gt;<a class="code" href="struct____splaylnk__node.html#a1b8aa83724dda5b481330b8ca569cdc0" title="父节点">parent</a> = NULL;
<a name="l00498"></a>00498     node-&gt;<a class="code" href="struct____splaylnk__node.html#aa0ed7aab4acf06a006c61aa96e4cd5a1" title="左子节点">left</a> = NULL;
<a name="l00499"></a>00499     node-&gt;<a class="code" href="struct____splaylnk__node.html#adbcf818bcfba554a383e453874ad29a4" title="右子节点">right</a> = NULL;
<a name="l00500"></a>00500 }
<a name="l00501"></a>00501 
<a name="l00510"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gaf66fad4729c1d2764ec32eee101b89d7">00510</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gaf66fad4729c1d2764ec32eee101b89d7" title="用新节点替换旧节点">splaylnk_iter_replace</a>(<a class="code" href="structsplaylnk__root.html" title="树根">splaylnk_root</a>* root, 
<a name="l00511"></a>00511                     splaylnk_iter victim, splaylnk_iter newly)
<a name="l00512"></a>00512 {
<a name="l00513"></a>00513     splaylnk_iter parent = <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga59c8e5d7719e7d97ef4d7b15ac31a4ff" title="得到父节点">splaylnk_parent</a>(victim);
<a name="l00514"></a>00514     
<a name="l00515"></a>00515     <span class="comment">/* 将victim父节点的孩子设为newly */</span>
<a name="l00516"></a>00516     <span class="keywordflow">if</span> (parent) {
<a name="l00517"></a>00517         <span class="keywordflow">if</span> (victim == parent-&gt;<a class="code" href="struct____splaylnk__node.html#aa0ed7aab4acf06a006c61aa96e4cd5a1" title="左子节点">left</a>)
<a name="l00518"></a>00518             parent-&gt;<a class="code" href="struct____splaylnk__node.html#aa0ed7aab4acf06a006c61aa96e4cd5a1" title="左子节点">left</a> = newly;
<a name="l00519"></a>00519         <span class="keywordflow">else</span>
<a name="l00520"></a>00520             parent-&gt;<a class="code" href="struct____splaylnk__node.html#adbcf818bcfba554a383e453874ad29a4" title="右子节点">right</a> = newly;
<a name="l00521"></a>00521     } <span class="keywordflow">else</span>
<a name="l00522"></a>00522         root-&gt;<a class="code" href="structsplaylnk__root.html#ad1a7b82ff33bd008821a73024d7c3576" title="根节点">node</a> = newly;
<a name="l00523"></a>00523     
<a name="l00524"></a>00524     <span class="comment">/* 重新确定victim孩子节点的父节点为newly */</span>
<a name="l00525"></a>00525     <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga0bc6c60eab55d8b1ff543b3bbd430277" title="仅在node不为空时，设置node的父节点">splaylnk_set_parent_if</a>(victim-&gt;<a class="code" href="struct____splaylnk__node.html#aa0ed7aab4acf06a006c61aa96e4cd5a1" title="左子节点">left</a>, newly);
<a name="l00526"></a>00526     <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga0bc6c60eab55d8b1ff543b3bbd430277" title="仅在node不为空时，设置node的父节点">splaylnk_set_parent_if</a>(victim-&gt;<a class="code" href="struct____splaylnk__node.html#adbcf818bcfba554a383e453874ad29a4" title="右子节点">right</a>, newly);
<a name="l00527"></a>00527     
<a name="l00528"></a>00528     <span class="comment">/* 替换节点成员 */</span>
<a name="l00529"></a>00529     *newly = *victim;
<a name="l00530"></a>00530 }
<a name="l00531"></a>00531 
<a name="l00538"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gaf49efefae965d599b54b7006507430da">00538</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gaf49efefae965d599b54b7006507430da" title="用新的树根替换旧树根">splaylnk_replace</a>(<a class="code" href="structsplaylnk__root.html" title="树根">splaylnk_root</a>* victim, 
<a name="l00539"></a>00539                                         <a class="code" href="structsplaylnk__root.html" title="树根">splaylnk_root</a>* newly)
<a name="l00540"></a>00540 {
<a name="l00541"></a>00541     newly-&gt;<a class="code" href="structsplaylnk__root.html#ad1a7b82ff33bd008821a73024d7c3576" title="根节点">node</a> = victim-&gt;<a class="code" href="structsplaylnk__root.html#ad1a7b82ff33bd008821a73024d7c3576" title="根节点">node</a>;
<a name="l00542"></a>00542 }
<a name="l00543"></a>00543 
<a name="l00550"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga9d10b0aaef216b49f5f3b979746c130b">00550</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga9d10b0aaef216b49f5f3b979746c130b" title="交换两个树">splaylnk_swap</a>(<a class="code" href="structsplaylnk__root.html" title="树根">splaylnk_root</a>* a, <a class="code" href="structsplaylnk__root.html" title="树根">splaylnk_root</a>* b)
<a name="l00551"></a>00551 {
<a name="l00552"></a>00552     splaylnk_iter t = a-&gt;<a class="code" href="structsplaylnk__root.html#ad1a7b82ff33bd008821a73024d7c3576" title="根节点">node</a>; a-&gt;<a class="code" href="structsplaylnk__root.html#ad1a7b82ff33bd008821a73024d7c3576" title="根节点">node</a> = b-&gt;<a class="code" href="structsplaylnk__root.html#ad1a7b82ff33bd008821a73024d7c3576" title="根节点">node</a>; b-&gt;<a class="code" href="structsplaylnk__root.html#ad1a7b82ff33bd008821a73024d7c3576" title="根节点">node</a> = t;
<a name="l00553"></a>00553 }
<a name="l00554"></a>00554 
<a name="l00564"></a>00564 NV_API <span class="keywordtype">int</span> <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gaa1f8902531ce41d20ed3fd88d6f8de69" title="判断一个节点是否存在于树中">splaylnk_exist</a>(<a class="code" href="structsplaylnk__root.html" title="树根">splaylnk_root</a>* root, splaylnk_iter itr);
<a name="l00565"></a>00565 
<a name="l00574"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga8ad8cae719494a3f15d181e8b9f4dc5b">00574</a> <span class="keyword">static</span> <span class="keyword">inline</span> splaylnk_iter <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga8ad8cae719494a3f15d181e8b9f4dc5b" title="得到正向索引对应的节点的迭代器">splaylnk_at</a>(<a class="code" href="structsplaylnk__root.html" title="树根">splaylnk_root</a>* root, <span class="keywordtype">size_t</span> index)
<a name="l00575"></a>00575 {
<a name="l00576"></a>00576     <span class="keywordflow">return</span> <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga270dd16e098a16b9631eb0a8f712ffb4" title="给迭代器增加一段距离或减小一段距离">splaylnk_advance</a>(<a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga4ea94db03f94aba84fb246f474a87df4" title="得到树的最左端节点">splaylnk_front</a>(root), index);
<a name="l00577"></a>00577 }
<a name="l00578"></a>00578 
<a name="l00588"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga2588af8914cc7c4399ca3b4dcd3a8d1e">00588</a> <span class="keyword">static</span> <span class="keyword">inline</span> splaylnk_iter <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga2588af8914cc7c4399ca3b4dcd3a8d1e" title="得到逆向索引对应的节点的迭代器">splaylnk_reverse_at</a>(<a class="code" href="structsplaylnk__root.html" title="树根">splaylnk_root</a>* root, <span class="keywordtype">size_t</span> index)
<a name="l00589"></a>00589 {
<a name="l00590"></a>00590     <span class="keywordflow">return</span> <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga270dd16e098a16b9631eb0a8f712ffb4" title="给迭代器增加一段距离或减小一段距离">splaylnk_advance</a>(<a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gab9dc4ef36e511ad52d1f16c167b1facd" title="得到树的最右端节点">splaylnk_back</a>(root), -(<span class="keywordtype">int</span>)(index));
<a name="l00591"></a>00591 }
<a name="l00592"></a>00592 
<a name="l00600"></a>00600 NV_API splaylnk_iter <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga4ea94db03f94aba84fb246f474a87df4" title="得到树的最左端节点">splaylnk_front</a>(<a class="code" href="structsplaylnk__root.html" title="树根">splaylnk_root</a>* root);
<a name="l00601"></a>00601 
<a name="l00609"></a>00609 NV_API splaylnk_iter <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gab9dc4ef36e511ad52d1f16c167b1facd" title="得到树的最右端节点">splaylnk_back</a>(<a class="code" href="structsplaylnk__root.html" title="树根">splaylnk_root</a>* root);
<a name="l00610"></a>00610 
<a name="l00618"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga2e0c221b5e448b08815f57083ab7f88d">00618</a> <span class="keyword">static</span> <span class="keyword">inline</span> splaylnk_iter <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga2e0c221b5e448b08815f57083ab7f88d" title="得到指向正向起始位置的迭代器">splaylnk_begin</a>(<a class="code" href="structsplaylnk__root.html" title="树根">splaylnk_root</a>* root)
<a name="l00619"></a>00619 {
<a name="l00620"></a>00620     <span class="keywordflow">return</span> <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga4ea94db03f94aba84fb246f474a87df4" title="得到树的最左端节点">splaylnk_front</a>(root);
<a name="l00621"></a>00621 }
<a name="l00622"></a>00622 
<a name="l00629"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga974718d49f7e2ffec9a0512f75144d10">00629</a> <span class="keyword">static</span> <span class="keyword">inline</span> splaylnk_iter <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga974718d49f7e2ffec9a0512f75144d10" title="得到指向正向终止位置的迭代器">splaylnk_end</a>()
<a name="l00630"></a>00630 {
<a name="l00631"></a>00631     <span class="keywordflow">return</span> NULL;
<a name="l00632"></a>00632 }
<a name="l00633"></a>00633 
<a name="l00641"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga195070ea85dfd413a26d9d060cd0ec5c">00641</a> <span class="keyword">static</span> <span class="keyword">inline</span> splaylnk_iter <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga195070ea85dfd413a26d9d060cd0ec5c" title="得到当前迭代器的正向终止位置">splaylnk_end_of</a>(splaylnk_iter cur)
<a name="l00642"></a>00642 {
<a name="l00643"></a>00643     <span class="keywordflow">return</span> <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga6fc0567f0310442cab65da24be50f6c6" title="得到当前节点的中序后继节点">splaylnk_next</a>(cur);
<a name="l00644"></a>00644 }
<a name="l00645"></a>00645 
<a name="l00653"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gab60f4495e69b5698230fd1e6f4f655ec">00653</a> <span class="keyword">static</span> <span class="keyword">inline</span> splaylnk_iter <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gab60f4495e69b5698230fd1e6f4f655ec" title="得到指向逆向起始位置的迭代器">splaylnk_rbegin</a>(<a class="code" href="structsplaylnk__root.html" title="树根">splaylnk_root</a>* root)
<a name="l00654"></a>00654 {
<a name="l00655"></a>00655     <span class="keywordflow">return</span> <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gab9dc4ef36e511ad52d1f16c167b1facd" title="得到树的最右端节点">splaylnk_back</a>(root);
<a name="l00656"></a>00656 }
<a name="l00657"></a>00657 
<a name="l00664"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga35ce6d814ceb12ede0d7ce2dc6c319f4">00664</a> <span class="keyword">static</span> <span class="keyword">inline</span> splaylnk_iter <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga35ce6d814ceb12ede0d7ce2dc6c319f4" title="得到指向逆向终止位置的迭代器">splaylnk_rend</a>()
<a name="l00665"></a>00665 {
<a name="l00666"></a>00666     <span class="keywordflow">return</span> NULL;
<a name="l00667"></a>00667 }
<a name="l00668"></a>00668 
<a name="l00676"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga6df1dae359180f19397c1ef01bbe1ccc">00676</a> <span class="keyword">static</span> <span class="keyword">inline</span> splaylnk_iter <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga6df1dae359180f19397c1ef01bbe1ccc" title="得到当前迭代器的逆向终止位置">splaylnk_rend_of</a>(splaylnk_iter cur)
<a name="l00677"></a>00677 {
<a name="l00678"></a>00678     <span class="keywordflow">return</span> <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga31c7ab1c0c602384c51537bc8c36cc4b" title="得到当前节点的中序前驱节点">splaylnk_prev</a>(cur);
<a name="l00679"></a>00679 }
<a name="l00680"></a>00680 
<a name="l00688"></a>00688 <span class="keyword">static</span> <span class="keyword">inline</span> splaylnk_iter <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga6df1dae359180f19397c1ef01bbe1ccc" title="得到当前迭代器的逆向终止位置">splaylnk_rend_of</a>(splaylnk_iter cur)
<a name="l00689"></a>00689 {
<a name="l00690"></a>00690     <span class="keywordflow">return</span> <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga31c7ab1c0c602384c51537bc8c36cc4b" title="得到当前节点的中序前驱节点">splaylnk_prev</a>(cur);
<a name="l00691"></a>00691 }
<a name="l00692"></a>00692 
<a name="l00700"></a>00700 NV_API splaylnk_iter <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga6fc0567f0310442cab65da24be50f6c6" title="得到当前节点的中序后继节点">splaylnk_next</a>(splaylnk_iter cur);
<a name="l00701"></a>00701 
<a name="l00709"></a>00709 NV_API splaylnk_iter <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga31c7ab1c0c602384c51537bc8c36cc4b" title="得到当前节点的中序前驱节点">splaylnk_prev</a>(splaylnk_iter cur);
<a name="l00710"></a>00710 
<a name="l00718"></a>00718 NV_API splaylnk_iter <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga270dd16e098a16b9631eb0a8f712ffb4" title="给迭代器增加一段距离或减小一段距离">splaylnk_advance</a>(splaylnk_iter cur, <span class="keywordtype">int</span> dist);
<a name="l00719"></a>00719 
<a name="l00730"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga7ce5153a6d1b663eae23b1afcf97d0c7">00730</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga7ce5153a6d1b663eae23b1afcf97d0c7" title="清空树">splaylnk_clear</a>(<a class="code" href="structsplaylnk__root.html" title="树根">splaylnk_root</a>* root, 
<a name="l00731"></a>00731                                 <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gac07a47df24523e66c8f37863d68b3d59" title="单参数回调函数指针">splaylnk_pr1</a> erase_handler)
<a name="l00732"></a>00732 {
<a name="l00733"></a>00733     <span class="keywordflow">if</span> (!<a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga328c554736cee464fd77d3e0e4135a05" title="判断树是否为空">splaylnk_empty</a>(root))
<a name="l00734"></a>00734         <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gaf8b8aa25afe97aafae97b716b29ef460" title="移除区域内的节点(伸展)">splaylnk_erases</a>(root, <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga4ea94db03f94aba84fb246f474a87df4" title="得到树的最左端节点">splaylnk_front</a>(root), NULL, erase_handler);
<a name="l00735"></a>00735 }
<a name="l00736"></a>00736 
<a name="l00737"></a>00737 <span class="keyword">static</span> <span class="keyword">inline</span> splaylnk_iter __splaylnk_inc_later(splaylnk_iter cur, 
<a name="l00738"></a>00738                                                     splaylnk_iter* p)
<a name="l00739"></a>00739 {
<a name="l00740"></a>00740     *p = <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga6fc0567f0310442cab65da24be50f6c6" title="得到当前节点的中序后继节点">splaylnk_next</a>(cur);
<a name="l00741"></a>00741     <span class="keywordflow">return</span> cur;
<a name="l00742"></a>00742 }
<a name="l00743"></a>00743 
<a name="l00744"></a>00744 <span class="keyword">static</span> <span class="keyword">inline</span> splaylnk_iter __splaylnk_dec_later(splaylnk_iter cur, 
<a name="l00745"></a>00745                                                     splaylnk_iter* p)
<a name="l00746"></a>00746 {
<a name="l00747"></a>00747     *p = <a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga31c7ab1c0c602384c51537bc8c36cc4b" title="得到当前节点的中序前驱节点">splaylnk_prev</a>(cur);
<a name="l00748"></a>00748     <span class="keywordflow">return</span> cur;
<a name="l00749"></a>00749 }
<a name="l00750"></a>00750 
<a name="l00761"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga6cfeb8883fb82004328680139dfbd127">00761</a> <span class="preprocessor">#define splaylnk_inc(itr)           ((itr) = splaylnk_next(itr))</span>
<a name="l00762"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga116d136bf37eb1a0ffb58157e3c06f23">00762</a> <span class="preprocessor"></span><span class="preprocessor">#define splaylnk_dec(itr)           ((itr) = splaylnk_prev(itr))</span>
<a name="l00763"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga2ccc72af8c152a19ede061ea516805bc">00763</a> <span class="preprocessor"></span><span class="preprocessor">#define splaylnk_inc_later(itr) __splaylnk_inc_later(itr, &amp;(itr))</span>
<a name="l00764"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gafef1af602fbe8324144e108ea3eb3de4">00764</a> <span class="preprocessor"></span><span class="preprocessor">#define splaylnk_dec_later(itr) __splaylnk_dec_later(itr, &amp;(itr))</span>
<a name="l00765"></a>00765 <span class="preprocessor"></span>
<a name="l00775"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga89842a2c5280c53314fcca579a625b39">00775</a> <span class="preprocessor">#define splaylnk_foreach(_begin, _end, fn, type, member) do {\</span>
<a name="l00776"></a>00776 <span class="preprocessor">        splaylnk_iter _q_e = (_end);                        \</span>
<a name="l00777"></a>00777 <span class="preprocessor">        splaylnk_iter _q_f = (_begin);                      \</span>
<a name="l00778"></a>00778 <span class="preprocessor">        while (_q_f != _q_e) {                              \</span>
<a name="l00779"></a>00779 <span class="preprocessor">            type * _q_t = container_of(_q_f, type, member); \</span>
<a name="l00780"></a>00780 <span class="preprocessor">            splaylnk_inc(_q_f);                             \</span>
<a name="l00781"></a>00781 <span class="preprocessor">            fn(_q_t);                                       \</span>
<a name="l00782"></a>00782 <span class="preprocessor">        }                                                   \</span>
<a name="l00783"></a>00783 <span class="preprocessor">    } while (0)</span>
<a name="l00784"></a>00784 <span class="preprocessor"></span>
<a name="l00794"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga2b8fc5d56894e2cdbe104e6841ac0a0b">00794</a> <span class="preprocessor">#define splaylnk_reverse_foreach(_rbegin, _rend, fn, type, member) do {\</span>
<a name="l00795"></a>00795 <span class="preprocessor">        splaylnk_iter _q_e = (_rend);                       \</span>
<a name="l00796"></a>00796 <span class="preprocessor">        splaylnk_iter _q_f = (_rbegin);                     \</span>
<a name="l00797"></a>00797 <span class="preprocessor">        while (_q_f != _q_e) {                              \</span>
<a name="l00798"></a>00798 <span class="preprocessor">            type * _q_t = container_of(_q_f, type, member); \</span>
<a name="l00799"></a>00799 <span class="preprocessor">            splaylnk_dec(_q_f);                             \</span>
<a name="l00800"></a>00800 <span class="preprocessor">            fn(_q_t);                                       \</span>
<a name="l00801"></a>00801 <span class="preprocessor">        }                                                   \</span>
<a name="l00802"></a>00802 <span class="preprocessor">    } while (0)</span>
<a name="l00803"></a>00803 <span class="preprocessor"></span>
<a name="l00804"></a>00804 NV_API <span class="keywordtype">void</span> __do_splaylnk_recurse_foreach(splaylnk_iter cur, 
<a name="l00805"></a>00805                                 <span class="keywordtype">void</span> (*fn)(<span class="keywordtype">void</span>*), <span class="keywordtype">size_t</span> offset);
<a name="l00806"></a>00806 
<a name="l00807"></a>00807 NV_API <span class="keywordtype">void</span> __do_splaylnk_recurse_reverse_foreach(
<a name="l00808"></a>00808                     splaylnk_iter cur, <span class="keywordtype">void</span> (*fn)(<span class="keywordtype">void</span>*), <span class="keywordtype">size_t</span> offset);
<a name="l00809"></a>00809 
<a name="l00810"></a>00810 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> __splaylnk_recurse_foreach(<a class="code" href="structsplaylnk__root.html" title="树根">splaylnk_root</a>* root, 
<a name="l00811"></a>00811                                 <span class="keywordtype">void</span> (*fn)(<span class="keywordtype">void</span>*), <span class="keywordtype">size_t</span> offset)
<a name="l00812"></a>00812 {
<a name="l00813"></a>00813     <span class="keywordflow">if</span> (fn)
<a name="l00814"></a>00814         __do_splaylnk_recurse_foreach(root-&gt;<a class="code" href="structsplaylnk__root.html#ad1a7b82ff33bd008821a73024d7c3576" title="根节点">node</a>, fn, offset);
<a name="l00815"></a>00815 }
<a name="l00816"></a>00816 
<a name="l00817"></a>00817 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> __splaylnk_recurse_reverse_foreach(
<a name="l00818"></a>00818     <a class="code" href="structsplaylnk__root.html" title="树根">splaylnk_root</a>* root, <span class="keywordtype">void</span> (*fn)(<span class="keywordtype">void</span>*), <span class="keywordtype">size_t</span> offset)
<a name="l00819"></a>00819 {
<a name="l00820"></a>00820     <span class="keywordflow">if</span> (fn)
<a name="l00821"></a>00821         __do_splaylnk_recurse_reverse_foreach(root-&gt;<a class="code" href="structsplaylnk__root.html#ad1a7b82ff33bd008821a73024d7c3576" title="根节点">node</a>, fn, offset);
<a name="l00822"></a>00822 }
<a name="l00823"></a>00823 
<a name="l00832"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gaee5f30c6073ff1b5ff61aa49a4e1b3e6">00832</a> <span class="preprocessor">#define SPLAYLNK_RECURSE_PROC(name, type, param) void name(type * param)</span>
<a name="l00833"></a>00833 <span class="preprocessor"></span>
<a name="l00857"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga35422cff5b679c86164f7d5f4fc9f33e">00857</a> <span class="preprocessor">#define splaylnk_recurse_foreach(root, fn, type, member) \</span>
<a name="l00858"></a>00858 <span class="preprocessor">    __splaylnk_recurse_foreach(root, (void (*)(void*))(fn), \</span>
<a name="l00859"></a>00859 <span class="preprocessor">            offset_of(type, member))</span>
<a name="l00860"></a>00860 <span class="preprocessor"></span>
<a name="l00870"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gaa5cd9e3a0e58373e79af482c36d30ce7">00870</a> <span class="preprocessor">#define splaylnk_recurse_reverse_foreach(root, fn, type, member) \</span>
<a name="l00871"></a>00871 <span class="preprocessor">    __splaylnk_recurse_reverse_foreach(root, (void (*)(void*))(fn), \</span>
<a name="l00872"></a>00872 <span class="preprocessor">            offset_of(type, member))</span>
<a name="l00873"></a>00873 <span class="preprocessor"></span>
<a name="l00902"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gaea739ab35bbd5434a9ab35468ef78bb5">00902</a> <span class="preprocessor">#define splaylnk_search(root, newly, greater, res, type, member) do {\</span>
<a name="l00903"></a>00903 <span class="preprocessor">        splaylnk_root* _k_r = (root);                           \</span>
<a name="l00904"></a>00904 <span class="preprocessor">        type * _k_pn = (newly);                                 \</span>
<a name="l00905"></a>00905 <span class="preprocessor">        splaylnk_iter _k_p = _k_r-&gt;node;                        \</span>
<a name="l00906"></a>00906 <span class="preprocessor">        (res) = NULL;                                           \</span>
<a name="l00907"></a>00907 <span class="preprocessor">        while (_k_p) {                                          \</span>
<a name="l00908"></a>00908 <span class="preprocessor">            type * _k_pr = container_of(_k_p, type, member);    \</span>
<a name="l00909"></a>00909 <span class="preprocessor">            if (greater(_k_pr, _k_pn))                          \</span>
<a name="l00910"></a>00910 <span class="preprocessor">                _k_p = _k_p-&gt;right;                             \</span>
<a name="l00911"></a>00911 <span class="preprocessor">            else if (greater(_k_pn, _k_pr))                     \</span>
<a name="l00912"></a>00912 <span class="preprocessor">                _k_p = _k_p-&gt;left;                              \</span>
<a name="l00913"></a>00913 <span class="preprocessor">            else {                                              \</span>
<a name="l00914"></a>00914 <span class="preprocessor">                (res) = _k_p; break;                            \</span>
<a name="l00915"></a>00915 <span class="preprocessor">            }                                                   \</span>
<a name="l00916"></a>00916 <span class="preprocessor">        }                                                       \</span>
<a name="l00917"></a>00917 <span class="preprocessor">    } while (0)</span>
<a name="l00918"></a>00918 <span class="preprocessor"></span>
<a name="l00947"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga0a9f60007851a8069b5cd7968f2829cd">00947</a> <span class="preprocessor">#define splaylnk_insert(root, newly, greater, res, type, member) do {\</span>
<a name="l00948"></a>00948 <span class="preprocessor">        splaylnk_root* _k_r = (root);                                   \</span>
<a name="l00949"></a>00949 <span class="preprocessor">        splaylnk_iter* _k_pp = &amp;_k_r-&gt;node;                             \</span>
<a name="l00950"></a>00950 <span class="preprocessor">        splaylnk_iter _k_n = (newly);                                   \</span>
<a name="l00951"></a>00951 <span class="preprocessor">        splaylnk_iter _k_p;                                             \</span>
<a name="l00952"></a>00952 <span class="preprocessor">        type * _k_pn = container_of(_k_n, type, member);                \</span>
<a name="l00953"></a>00953 <span class="preprocessor">        (res) = 1;                                                      \</span>
<a name="l00954"></a>00954 <span class="preprocessor">        splaylnk_node_init(_k_n);                                       \</span>
<a name="l00955"></a>00955 <span class="preprocessor">        while (*_k_pp) {                                                \</span>
<a name="l00956"></a>00956 <span class="preprocessor">            type * _k_pr = container_of(_k_p = *_k_pp, type, member);   \</span>
<a name="l00957"></a>00957 <span class="preprocessor">            if (greater(_k_pr, _k_pn))                                  \</span>
<a name="l00958"></a>00958 <span class="preprocessor">                _k_pp = &amp;_k_p-&gt;left;                                    \</span>
<a name="l00959"></a>00959 <span class="preprocessor">            else if (greater(_k_pn, _k_pr))                             \</span>
<a name="l00960"></a>00960 <span class="preprocessor">                _k_pp = &amp;_k_p-&gt;right;                                   \</span>
<a name="l00961"></a>00961 <span class="preprocessor">            else {                                                      \</span>
<a name="l00962"></a>00962 <span class="preprocessor">                (res) = 0; break;                                       \</span>
<a name="l00963"></a>00963 <span class="preprocessor">            }                                                           \</span>
<a name="l00964"></a>00964 <span class="preprocessor">        }                                                               \</span>
<a name="l00965"></a>00965 <span class="preprocessor">        if (res) {                                                      \</span>
<a name="l00966"></a>00966 <span class="preprocessor">            splaylnk_link(_k_n, _k_p, _k_pp);                           \</span>
<a name="l00967"></a>00967 <span class="preprocessor">            splaylnk_splay(_k_r, _k_n, _k_p);                           \</span>
<a name="l00968"></a>00968 <span class="preprocessor">        }                                                               \</span>
<a name="l00969"></a>00969 <span class="preprocessor">    } while (0)</span>
<a name="l00970"></a>00970 <span class="preprocessor"></span>
<a name="l00999"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga1a27b1f3785635d8776aa390682cb54b">00999</a> <span class="preprocessor">#define splaylnk_semi_insert(root, newly, greater, res, type, member) do {\</span>
<a name="l01000"></a>01000 <span class="preprocessor">        splaylnk_root* _k_r = (root);                       \</span>
<a name="l01001"></a>01001 <span class="preprocessor">        splaylnk_iter* _k_pp = &amp;_k_r-&gt;node;                 \</span>
<a name="l01002"></a>01002 <span class="preprocessor">        splaylnk_iter _k_n = (newly);                       \</span>
<a name="l01003"></a>01003 <span class="preprocessor">        splaylnk_iter _k_p;                                 \</span>
<a name="l01004"></a>01004 <span class="preprocessor">        type * _k_pn = container_of(_k_n, type, member);    \</span>
<a name="l01005"></a>01005 <span class="preprocessor">        (res) = 1;                                          \</span>
<a name="l01006"></a>01006 <span class="preprocessor">        splaylnk_node_init(_k_n);                           \</span>
<a name="l01007"></a>01007 <span class="preprocessor">        while (*_k_pp) {                                    \</span>
<a name="l01008"></a>01008 <span class="preprocessor">            _k_p = *_k_pp;                                  \</span>
<a name="l01009"></a>01009 <span class="preprocessor">            _k_pr = container_of(_k_p, type, member);       \</span>
<a name="l01010"></a>01010 <span class="preprocessor">            if (greater(_k_pr, _k_pn))                      \</span>
<a name="l01011"></a>01011 <span class="preprocessor">                _k_pp = &amp;_k_p-&gt;left;                        \</span>
<a name="l01012"></a>01012 <span class="preprocessor">            else if (greater(_k_pn, _k_pr))                 \</span>
<a name="l01013"></a>01013 <span class="preprocessor">                _k_pp = &amp;_k_p-&gt;right;                       \</span>
<a name="l01014"></a>01014 <span class="preprocessor">            else {                                          \</span>
<a name="l01015"></a>01015 <span class="preprocessor">                (res) = 0; break;                           \</span>
<a name="l01016"></a>01016 <span class="preprocessor">            }                                               \</span>
<a name="l01017"></a>01017 <span class="preprocessor">        }                                                   \</span>
<a name="l01018"></a>01018 <span class="preprocessor">        if (res) {                                          \</span>
<a name="l01019"></a>01019 <span class="preprocessor">            splaylnk_link(_k_n, _k_p, _k_pp);               \</span>
<a name="l01020"></a>01020 <span class="preprocessor">            splaylnk_semisplay(_k_r, _k_n, _k_p);           \</span>
<a name="l01021"></a>01021 <span class="preprocessor">        }                                                   \</span>
<a name="l01022"></a>01022 <span class="preprocessor">    } while (0)</span>
<a name="l01023"></a>01023 <span class="preprocessor"></span>
<a name="l01024"></a>01024 NV_API <span class="keywordtype">void</span> __splaylnk_serialize(<a class="code" href="structsplaylnk__root.html" title="树根">splaylnk_root</a>* root, 
<a name="l01025"></a>01025                                     <span class="keywordtype">void</span>** buf, <span class="keywordtype">size_t</span> offset);
<a name="l01026"></a>01026 
<a name="l01027"></a>01027 NV_API <span class="keywordtype">void</span> __splaylnk_deserialize(<a class="code" href="structsplaylnk__root.html" title="树根">splaylnk_root</a>* root, <span class="keywordtype">char</span>** buf, 
<a name="l01028"></a>01028                                         <span class="keywordtype">size_t</span> cnt, <span class="keywordtype">size_t</span> offset);
<a name="l01029"></a>01029 
<a name="l01039"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#ga3b4c9997a7ac852a073efff7579e298b">01039</a> <span class="preprocessor">#define splaylnk_serialize(root, buf, type, member) \</span>
<a name="l01040"></a>01040 <span class="preprocessor">    __splaylnk_serialize(root, (void**)(buf), offset_of(type, member))</span>
<a name="l01041"></a>01041 <span class="preprocessor"></span>
<a name="l01052"></a><a class="code" href="group___xE4_xBC_xB8_xE5_xB1_x95_xE6_xA0_x91.html#gaf97a19ddb43b97be82103097ecad127b">01052</a> <span class="preprocessor">#define splaylnk_deserialize(root, buf, cnt, type, member) \</span>
<a name="l01053"></a>01053 <span class="preprocessor">    __splaylnk_deserialize(root, (char**)(buf), cnt, offset_of(type, member))</span>
<a name="l01054"></a>01054 <span class="preprocessor"></span>
<a name="l01057"></a>01057 <span class="preprocessor">#ifdef __cplusplus</span>
<a name="l01058"></a>01058 <span class="preprocessor"></span>}
<a name="l01059"></a>01059 <span class="preprocessor">#endif  </span><span class="comment">/* #ifdef __cplusplus */</span>
<a name="l01060"></a>01060 
<a name="l01061"></a>01061 <span class="preprocessor">#endif  </span><span class="comment">/* #ifndef __NV_SPLAYLNK__ */</span>
<a name="l01062"></a>01062 
</pre></div></div>
</div>
<!--- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>全部</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>数据结构</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>文件</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>函数</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>变量</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>类型定义</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>宏定义</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<hr class="footer"/><address class="footer"><small>Generated at 2015年七月16日 星期四 12:00:37 for Navo Portable Library by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.3 </small></address>
</body>
</html>
